package STUDENT.TRANBANGTUNG.day05_20_2016.bai1;

public class Model {

	public double tinhtong(Object obj) {
		double[] array = obj.getArray();
		double tong = 0;
		for (int i = 0; i < array.length; i++) {
			tong += array[i];
		}
		return tong;
	}

	public double max(Object obj) {
		double[] array = obj.getArray();
		double max = array[0];
		for (int i = 0; i < array.length; i++) {
			if (max < array[i]) {
				max = array[i];
			}
		}
		return max;
	}

	public double min(Object obj) {
		double[] array = obj.getArray();
		double min = array[0];
		for (int i = 0; i < array.length; i++) {
			if (min > array[i]) {
				min = array[i];
			}
		}
		return min;
	}

	public String dsmax(Object obj) {
		double[] array = obj.getArray();
		double max = array[0];
		String ds = "";
		for (int i = 0; i < array.length; i++) {
			if (max < array[i]) {
				max = array[i];
			}
		}
		for (int i = 0; i < array.length; i++) {
			if (array[i] == max) {
				if (ds.isEmpty()) {
					ds += i;
				} else {
					ds += "-" + i;
				}
			}
		}
		return ds;
	}
}
